Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue in vectorized get_dark_cal_id #274

Merged
merged 2 commits into from
Jul 8, 2022
Merged

Conversation

javierggt
Copy link
Contributor

@javierggt javierggt commented Jul 8, 2022

Description

This fixes a bug found in regression testing. get_dark_cal_id is vectorized using np.vectorize. When the input is a scalar, it returns a numpy scalar, but that is a numpy array with shape (). This has overloaded the bracket operators, so you can't call the bracket operators on the result. The solution is to return a scalar of the dtype's type.

Interface impacts

None

Testing

mica unit tests and sparkles tests pass (including a new test for this)

Unit tests

  • Mac

Independent check of unit tests by [REVIEWER NAME]

  • [PLATFORM]:

Functional tests

@javierggt javierggt force-pushed the dark-cal-vector-fix branch from 856a0c6 to c049a5d Compare July 8, 2022 19:17
dark_id = _get_dark_cal_id_vector(date, select=select)
if not dark_id.shape:
# returning an instance of the type, not a numpy array
return dark_id.dtype.type(dark_id)
Copy link
Member

@taldcroft taldcroft Jul 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that dark_id.tolist() is a more standard idiom to get back to a pure Python representation. In this case tolist() will return a str object instead of a numpy.str_ object. Even though they are basically compatible they are still different object types and the original API was str.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to use tolist().

@javierggt javierggt merged commit 620fe92 into master Jul 8, 2022
This was referenced Jul 8, 2022
@javierggt javierggt mentioned this pull request Aug 10, 2022
@javierggt javierggt deleted the dark-cal-vector-fix branch January 5, 2023 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants